package com.tkjt.pms.modules.repos.thread;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tkjt.pms.common.entity.TkIndexValueImport;
import com.tkjt.pms.impt.vos.UpdateCIndexVo;
import com.tkjt.pms.impt.vos.UpdateGIndexVo;
import com.tkjt.pms.modules.common.service.TkIndexValueImportService;
import com.tkjt.pms.modules.repos.service.IndexRepoService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams;

import java.io.File;
import java.util.List;

public class ConfirmDataThread implements Runnable{

    private String dataType;

    private String indexYearMonth;

    private IndexRepoService indexRepoService;

    private TkIndexValueImportService tkIndexValueImportService;

    private QueryWrapper<TkIndexValueImport> importQueryWrapper;

    public ConfirmDataThread(String dataType, String indexYearMonth, IndexRepoService indexRepoService,TkIndexValueImportService tkIndexValueImportService,QueryWrapper<TkIndexValueImport> importQueryWrapper) {
        this.dataType = dataType;
        this.indexYearMonth = indexYearMonth;
        this.indexRepoService = indexRepoService;
        this.tkIndexValueImportService = tkIndexValueImportService;
        this.importQueryWrapper = importQueryWrapper;
    }

    @Override
    public void run() {
        try{
            TkIndexValueImport tkIndexValueImport = new TkIndexValueImport();
            tkIndexValueImport.setIndexYearMonth(indexYearMonth);
            tkIndexValueImport.setDataType(dataType);
            indexRepoService.confirmImportData(tkIndexValueImport);
            tkIndexValueImport.setIndexValueStatus("1");
            tkIndexValueImportService.update(tkIndexValueImport,importQueryWrapper);
        }catch (Exception e){
            TkIndexValueImport tkIndexValueImport = new TkIndexValueImport();
            tkIndexValueImport.setIndexValueStatus("2");
            tkIndexValueImportService.update(tkIndexValueImport,importQueryWrapper);
        }
    }
}